﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SlideshowGenerator
{
    public partial class Frm_ImagePreview : Form
    {
        private Image _previewImage;

        public Frm_ImagePreview(Image previewImage)
        {
            InitializeComponent();
            _previewImage = previewImage;
            this.Size = _previewImage.Size;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            //do nothing
        }

        protected override void OnPaintBackground(PaintEventArgs e)
        {
            Graphics gfx = e.Graphics;
            gfx.DrawImage(_previewImage, new RectangleF(new PointF(0, 0), _previewImage.Size));
        }

        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);

            this.Dispose();
        }

        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            base.OnKeyPress(e);

            if (e.KeyChar == (char)Keys.Escape)
            {
                this.Dispose();
            }
        }
    }
}
